package com.vgmobile.cucrever2.home.category;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.vgmobile.cucrever2.R;
import com.vgmobile.cucrever2.api.ItemListHoz;
import com.vgmobile.cucrever2.global.BaseActivity;

public class ListCategoryAdapter extends BaseAdapter{
	
	public ArrayList<ItemListHoz> listItem;
	private LayoutInflater layoutInflater;
	
	public ListCategoryAdapter(BaseActivity activity, ArrayList<ItemListHoz> listItem) {
		this.listItem = listItem;
		layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listItem.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	@Override
	public View getView(int position , View convertView, ViewGroup parent){
		View view = convertView;
        ViewHolder viewHolder = null;
        if (convertView == null) {
        	view = layoutInflater.inflate(R.layout.category_parent_list_item, null);
        	viewHolder = new ViewHolder();
        	viewHolder.textView = (TextView) view.findViewById(R.id.category_parent_item_text);
        	view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.textView.setText(listItem.get(position).getTitle());
    	return view;
	}
	
	class ViewHolder{
		TextView textView;
	}
}
